﻿using IdentityServer4;
using IdentityServer4.Models;
using IdentityServer4.Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AuthServer.Configuration
{
    public class InMemoryConfiguration
    {
        public static IEnumerable<ApiResource> ApiResources()
        {
            return new[]
             {            
    new ApiResource("socialnetwork", "社交网络")
            };
        }



        public static IEnumerable<Client> Clients()
        {
            return new[]
   {                new Client
                {
                    ClientId = "socialnetwork",
                    ClientSecrets = new [] { new Secret("secret".Sha256()) },
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
                    AllowedScopes = new [] { "socialnetwork" }
                },
                new Client
                {
                     ClientId="mvc_client",
                     ClientName="MVC Client",
                      AllowedGrantTypes=GrantTypes.Implicit,
                      RedirectUris={ "http://localhost:2948/signin-oidc" },
                      PostLogoutRedirectUris={"http://localhost:2948/signout-callback-oidc" },
                      AllowedScopes=new List<string>
                      {
                          IdentityServerConstants.StandardScopes.OpenId,
                           IdentityServerConstants.StandardScopes.Profile,
                           "socialnetwork"

                      }
                }
            };
        }
        public static IEnumerable<IdentityResource> GetIdentityResources()
        {
            return new List<IdentityResource>
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile()

            };
        }
        public static IEnumerable<TestUser> Users()
        {
            return new[]{
                new TestUser
                {
                    SubjectId = "1",
                    Username = "mail@qq.com",
                    Password = "123qwe"
                }
            };
        }
    }
}
